home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------
- //
- // Filename : tetramino.h
- // Description : Header file for Tetramino class
- // Author : Marnich van Rensburg (2002)
- //
- //----------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------
-
- #include "timer.h"
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- #ifndef TETRAMINO_H
- #define TETRAMINO_H
-
- //Tetramino types
- #define I 1
- #define J 2
- #define L 3
- #define O 4
- #define S 5
- #define T 6
- #define Z 7
-
- #define TET_MAX_TYPES 7
-
- // default (x, y) starting positions
- #define TET_START_POS_X 0
- #define TET_START_POS_Y 0
-
-
-
- //----------------------------------------------------------------------------------------
- // Class Definition for Tetramino Class
- //----------------------------------------------------------------------------------------
-
- class Tetramino
- {
- //---------------------- Public -------------------------
-
- public:
-
- char Type;
- char CurrentRotation; // Current rotation state of tetramino
- float Speed; // Rate at which the tetramino falls
- char x, y; // Position in the container
- Timer Tmr; // Used for timing fall rate
-
- Tetramino(); // Constructor
- void New(char Type, unsigned int Level); // Inits a tetrmino based on type and level passed
- bool DropToNextRow(); // Returns true if the tetramino should drop to the next row
- void MoveRight(); // Moves tetramino one Right
- void MoveLeft(); // Moves tetramino one Left
- void MoveUp(); // Moves tetramino one Up
- void MoveDown(); // Moves tetramino one Down
- void RotateRight(); // Rotates the tetramino right
- void RotateLeft(); // Rotates the tetramino left
- void SetMatrix(char x, char y, bool Data); // Assigns data for teramino cell at (x, y)
- bool GetMatrix(char x, char y); // Returns the value of the teramino cell at (x, y)
-
- //---------------------- Private -------------------------
-
- private:
- bool Matrix[4][4]; // Holds shape data for the tetramino in a 4x4 matrix
-
- // Insert tetrmino data into matrix based on type and rotation passed
- void AssignData(char Type, char Rotation);
-
- };//Class Tetramino
-
- #endif;